import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './assets/main.css'

import VueMarkdownEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';
import Prism from 'prismjs';


import "./jqueryconfig"

const app = createApp(App)
VueMarkdownEditor.use(vuepressTheme, {
  config: {
    toc: {
      includeLevel: [1,2,3,4],
    },
  },
},);

//挂载路由导航守卫
router.beforeEach((to, from, next) => {
  //to 表示要访问的路径
  //from 代表从哪一个路径跳转而来
  //next 是一个函数，表示放行
  //    next()  放行    next('/login') 强制跳转

  if (to.path === '/login') return next();
  //获取token
  const tokenStr = localStorage.getItem('token')
  //如果没有获取到token那么返回登录
  if (tokenStr == '0000'){
    // console.log(123);
    return next('/login')
  } 
  
  //得到token就跳转页面，放行
  next()
})


app.use(router)
app.use(ElementPlus)
app.use(VueMarkdownEditor)

app.mount('#app')